<script>
	import config from 'common/js/config.js'
	import helper from 'common/js/helper.js'
	let socketTask;
	export default {
		onLaunch: function() {
			// #ifdef APP-PLUS
			plus.push.addEventListener('click', function(message) {
				if (message.payload == 1) {
					uni.navigateTo({
						url: '/pages/message/instantmsg/notice/noticeInfo/noticeInfo',
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				} else if (message.payload == 2) {
					uni.navigateTo({
						url: '/pages/message/instantmsg/system/systemInfo/systemInfo',
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				} else {
					uni.navigateTo({
						url: '/pages/message/instantmsg/private/privateInfo/privateInfo',
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}
			});
			plus.push.addEventListener('receive', function(message) {
				if (message.type == "receive") {
					plus.push.createMessage(message.content, message.payload);
				}
			}, false);
			plus.globalEvent.addEventListener('newintent', (e) => {
				var args = plus.runtime.arguments;
				if (args) {
					// 处理args参数，如直达到某新页面等  
					// console.log("newintent");
				}
			});
			// #endif
			// console.log('App Launch')
		},
		onShow: function() {
			// #ifdef APP-PLUS
			setTimeout(function() {
				var args = plus.runtime.arguments;
				if (args) {
					// 处理args参数，如直达到某新页面等  
					uni.reLaunch({
						url: '/pages/users/sign-in/sign-in',
					});
					// console.log(args);
				}
			}, 10);
			// #endif
			// console.log('App Show')
		},
		onHide: function() {
			// console.log('App Hide');
			if (this.$store.state.wschat.socketState) {
				setTimeout(() => {
					uni.closeSocket();
					this.$store.state.wschat.socketState = false;
				}, 90000);
			}
			// #ifdef APP-PLUS
			// var watchId = plus.geolocation.watchPosition(function(p) {
			// 	// console.log("监听位置变化信息:");
			// 	// console.log(JSON.stringify(p));
			// }, function(e) {
			// 	// console.log("监听位置变化信息失败：" + e.message);
			// }, {
			// 	'enableHighAccuracy': true,
			// 	'geocode': false
			// });
			// #endif
			uni.hideKeyboard();
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import './common/uni.css';
	/* @import './common/font/iconfont.css'; */	
	@import url('./static/font_custom/iconfont.css');
	@import url('./static/font_ym/iconfont.css');
	@import "uview-ui/index.scss";
</style>
